window.onload = function() {
	$('#btn').click(function (e) {
		e.preventDefault();
		let username = $('#username').val();
		let password = $('#password').val();
		if(username.length === 0 || password.length === 0) {
			alert('请输入用户名密码')
			return
		}
		
		$.ajax ({
			type:"GET",
			url:`http://localhost:8082/user/login?username=${username}&password=${password}`,
			dataType:"json",
			success: function(response) {
				if (response.isOk) {
					alert('欢迎你，' + response.info.name)
					
					s = response.info.name
					$(document).ready(function(){
						localStorage.setItem("0",s);
					});
					window.location.href='content.html'
					
					// top.location='http://127.0.0.1:8848/app/content.html'
				}else {
					alert('用户名错误')
				}
			}
		})
		
	});
}